home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Duchess.dxr / playing cards_58_tableau cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  7.0 KB  |  206 lines

  1. property spriteNum, row, motion, location, fp
  2. global tableau, stock, equal, getlist, godlist, reserve, currentsel, dimpos, extras, points, foundation
  3.  
  4. on beginSprite me
  5.   row = determinerow()
  6.   location = sprite(spriteNum).loc
  7.   if not objectp(tableau[row]) then
  8.     tableau.addProp(row, new(script("card pile")))
  9.     sprite(spriteNum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  10.     stock.cards.deleteAt(1)
  11.     tableau[row].addCard(spriteNum)
  12.   end if
  13.   candd = [#one: 37, #two: 51, #thr: 65, #fou: 79]
  14.   fp = candd[row]
  15. end
  16.  
  17. on determinerow me
  18.   if (spriteNum >= 37) and (spriteNum <= 50) then
  19.     return #one
  20.   else
  21.     if (spriteNum >= 51) and (spriteNum <= 64) then
  22.       return #two
  23.     else
  24.       if (spriteNum >= 65) and (spriteNum <= 78) then
  25.         return #thr
  26.       else
  27.         if (spriteNum >= 79) and (spriteNum <= 92) then
  28.           return #fou
  29.         end if
  30.       end if
  31.     end if
  32.   end if
  33. end
  34.  
  35. on mouseDown me
  36.   if sprite(spriteNum).member <> member("empty", "playing cards") then
  37.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  38.     if spriteNum = tableau[row].getlastcard().spnum then
  39.       sprite(spriteNum).locZ = spriteNum + 1000
  40.       getlist = tableau[row]
  41.       motion = timeout(string(spriteNum)).new(5, #moving, me)
  42.     else
  43.       runcheck()
  44.     end if
  45.   else
  46.     sendSprite(spriteNum - 1, #mouseDown)
  47.   end if
  48. end
  49.  
  50. on moving me
  51.   if the mouseDown then
  52.     sprite(spriteNum).loc = the mouseLoc
  53.   else
  54.     if the mouseUp then
  55.       motion.forget()
  56.       sprite(spriteNum).locZ = spriteNum
  57.       abort()
  58.     end if
  59.   end if
  60. end
  61.  
  62. on mouseUp me
  63.   if equal then
  64.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  65.     if extras.count = 0 then
  66.       sprite(currentsel).member = member(sprite(spriteNum).member.name, "playing cards")
  67.       godlist.addCard(currentsel)
  68.       tableau[row].cards.deleteOne(tableau[row].getlastcard())
  69.       sprite(spriteNum).member = member("empty", "playing cards")
  70.       sprite(spriteNum).loc = location
  71.     else
  72.       if extras.count > 0 then
  73.         extras.sort()
  74.         repeat with i = 0 to extras.count - 1
  75.           sprite(currentsel + i).member = member(sprite(the clickOn + i).member.name, "playing cards")
  76.           sprite(the clickOn + i).member = member("empty", "playing cards")
  77.           godlist.addCard(currentsel + i)
  78.           tableau[row].cards.deleteAt(tableau[row].getcardcount())
  79.           sprite(the clickOn + i).loc = sprite(the clickOn + i).location
  80.         end repeat
  81.         extras.deleteAll()
  82.       end if
  83.     end if
  84.     getlist = VOID
  85.     godlist = VOID
  86.     equal = 0
  87.     if objectp(foundation[sprite(currentsel).row]) then
  88.       points = points + 10
  89.     end if
  90.     checkwin()
  91.     currentsel = 0
  92.     repeat with i = 93 to 96
  93.       if tableau[sprite(i).row].getcardcount() > 0 then
  94.         sprite(i).loc = tableau[sprite(i).row].getlastcard().location
  95.         next repeat
  96.       end if
  97.       sprite(i).loc = sprite(fp).loc
  98.     end repeat
  99.   else
  100.     if not equal then
  101.       puppetSound(3, member("drop card", "100GPak Generic SFX"))
  102.       sprite(spriteNum).loc = location
  103.       getlist = VOID
  104.       if extras > 0 then
  105.         repeat with i = 1 to extras.count
  106.           sprite(extras[i]).loc = sprite(extras[i]).location
  107.         end repeat
  108.         extras.deleteAll()
  109.       end if
  110.     end if
  111.   end if
  112.   if tableau[row].getcardcount() = 0 then
  113.     sprite(fp - 1).member = member("empty", "playing cards")
  114.   end if
  115.   repeat with i = 93 to 96
  116.     if tableau[sprite(i).row].getcardcount() > 0 then
  117.       sprite(i).loc = tableau[sprite(i).row].getlastcard().location
  118.       next repeat
  119.     end if
  120.     sprite(i).loc = sprite(i).loki
  121.   end repeat
  122. end
  123.  
  124. on runcheck me
  125.   ass = 0
  126.   repeat with i = 1 to tableau[row].getcardcount()
  127.     if tableau[row].cards[i].spnum = spriteNum then
  128.       ss = i
  129.       dimpos = i
  130.       exit repeat
  131.     end if
  132.   end repeat
  133.   tt = ss + 1
  134.   repeat with ret = tt to tableau[row].getcardcount()
  135.     if tableau[row].cards[ret].suitcolor = tableau[row].cards[ret - 1].suitcolor then
  136.       exit repeat
  137.     end if
  138.     if (tableau[row].cards[ret].rankvalue <> (tableau[row].cards[ret - 1].rankvalue - 1)) and ((tableau[row].cards[ret].rankvalue <> 13) and (tableau[row].cards[ret - 1].rankvalue <> 1)) then
  139.       exit repeat
  140.     end if
  141.     if ret <> tableau[row].getcardcount() then
  142.       next repeat
  143.     end if
  144.     ass = 1
  145.   end repeat
  146.   if ass then
  147.     getlist = tableau[sprite(tableau[row].cards[i].spnum).row]
  148.     sprite(tableau[row].cards[ss].spnum).locZ = tableau[row].cards[ss].spnum + 1000
  149.     sprite(tableau[row].cards[ss].spnum).motion = timeout(string(row) && string(spriteNum)).new(5, #moving, sprite(tableau[row].cards[ss].spnum))
  150.     extras.add(spriteNum)
  151.     repeat with ret = tt to tableau[row].getcardcount()
  152.       sprite(tableau[row].cards[ret].spnum).locZ = tableau[row].cards[ret].spnum + 1000
  153.       sprite(tableau[row].cards[ret].spnum).motion = timeout(string(row) && string(tableau[row].cards[ret].spnum)).new(1, #keepintouch, sprite(tableau[row].cards[ret].spnum))
  154.       extras.add(tableau[row].cards[ret].spnum)
  155.     end repeat
  156.   end if
  157. end
  158.  
  159. on keepintouch me
  160.   if the mouseDown then
  161.     sprite(spriteNum).loc = point(the mouseH, sprite(spriteNum - 1).locV + 25)
  162.   else
  163.     if the mouseUp then
  164.       sprite(spriteNum).locZ = spriteNum
  165.       motion.forget()
  166.       abort()
  167.     end if
  168.   end if
  169. end
  170.  
  171. on backCardEQ me
  172.   if spriteNum <> fp then
  173.     if (sprite(spriteNum - 1).member.name <> "backofcard") and (sprite(spriteNum - 1).member.name <> "empty") then
  174.       if (getValue(sprite(spriteNum).member.name) = (getValue(sprite(spriteNum - 1).member.name) - 1)) and (getSuitCo(sprite(spriteNum).member.name) <> getSuitCo(sprite(spriteNum - 1).member.name)) then
  175.         repeat with shit = spriteNum - 1 to spriteNum - 1
  176.           repeat with cakes = 1 to tableau.count
  177.             if tableau[cakes].getcardcount() = 0 then
  178.               next repeat
  179.             end if
  180.             if (getValue(sprite(shit).member.name) = (getValue(sprite(tableau[cakes].getlastcard().spnum).member.name) - 1)) and (getSuitCo(sprite(shit).member.name) <> getSuitCo(sprite(tableau[cakes].getlastcard().spnum).member.name)) and not getduplicateme(tableau[cakes].getlastcard().spnum) then
  181.               return 1
  182.               exit
  183.               next repeat
  184.             end if
  185.             if (getValue(sprite(shit).member.name) = 13) and (getValue(sprite(tableau[cakes].getlastcard().spnum).member.name) = 1) and (getSuitCo(sprite(shit).member.name) <> getSuitCo(sprite(tableau[cakes].getlastcard().spnum).member.name)) and not getduplicateme(tableau[cakes].getlastcard().spnum) then
  186.               return 1
  187.             end if
  188.           end repeat
  189.         end repeat
  190.       else
  191.         sendSprite(spriteNum - 1, #backCardEQ)
  192.       end if
  193.     end if
  194.   end if
  195.   return 0
  196. end
  197.  
  198. on getduplicateme me, argu
  199.   if (sprite(spriteNum - 1).member.name <> "empty") and (sprite(spriteNum - 1).member.name <> "backofcard") then
  200.     if (getValue(sprite(spriteNum - 1).member.name) = getValue(sprite(argu).member.name)) and (getSuitCo(sprite(spriteNum - 1).member.name) = getSuitCo(sprite(argu).member.name)) then
  201.       return 1
  202.     end if
  203.   end if
  204.   return 0
  205. end
  206.